using System;
using System.Collections.Generic;

namespace Game {
    public class NPC {
        public NPCDisplay GameInstance {
            get;
            private set;
        }

        private Dictionary<Type, NPCModule> mModuleDic = new();

        public NPC(NPCDisplay display) {
            GameInstance = display;
        }

        public bool Has<T>() {
            return mModuleDic.ContainsKey(typeof(T));
        }
        
        public void Add<T>() where T : NPCModule,new() {
            if (!mModuleDic.ContainsKey(typeof(T))) {
                T module = new T();
                mModuleDic.Add(typeof(T),module);   
            }
        }

        public T Get<T>() where T : NPCModule,new() {
            if (mModuleDic.ContainsKey(typeof(T))) {
                return mModuleDic[typeof(T)] as T;
            }
            return default;
        }
        
    }   
}
